package com.xiaoshuidi.cloud.module.rooms.enums;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
@AllArgsConstructor
public enum RepairReasonEnum {
    QUALITYPROBLEM("1", "质量问题"),
    ARTIFICIALDAMAGE("2", "人为损坏"),
    EQUIPMENTAGING("3", "设备老化"),
    REPLACEACCESSORIES("4", "更换配件"),
    OTHER("5", "其他");

    private String code;
    private String name;

    public static String getNameByCode(String code) {
        if (StrUtil.isEmpty(code)) {
            return null;
        }
        Optional<RepairReasonEnum> find = Arrays.stream(RepairReasonEnum.values()).filter(s -> (s.getCode().equals(code))).findFirst();
        if (find.isPresent()) {
            return find.get().getName();
        }
        return null;
    }
}
